package org.zfes.snowier.zbss.xzy.router.user.message;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.web.util.FileResInfo;
import org.zfes.snowier.web.util.UploadUitl;
import org.zfes.snowier.zbss.xzy.base.HosConst;
import org.zfes.snowier.zbss.xzy.biz.message.model.Message;
import org.zfes.snowier.zbss.xzy.biz.message.service.IMessageService;
import org.zfes.snowier.zbss.xzy.biz.vedio.model.CloudImage;
import org.zfes.snowier.zbss.xzy.biz.vedio.service.ICloudImageService;
import org.zfes.snowier.zbss.xzy.biz.vedio.service.ICloudVedioService;
import org.zfes.snowier.zbss.xzy.message.MessageInfoDto;

import com.google.common.collect.Sets;

import io.swagger.annotations.ApiOperation;

import org.zfes.snowier.core.data.SelectVo;
@Controller("org.zfes.snowier.zbss.xzy.router.user.message.MessageController") 
@RequestMapping("/api/user/message")
public class MessageController implements BaseController {

	
	@Autowired
	private IMessageService messageService;

	@Autowired
	private ICloudVedioService cloudVedioService;
	
	@Autowired
	private ICloudImageService cloudImageService;
	
	 
	  @ApiOperation(value = "加载信息详情")
	  @RequestMapping(value="/loadMsgInfo/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	  public  @ResponseBody Object loadMsgInfo(@PathVariable("id") Long id ){
		  Optional<MessageInfoDto>  massage =messageService.loadMessageInfoById(id);
		 return ajaxQuery("massage", massage);
	  }
	  
	  @ApiOperation(value = "获取图片证据url")
	  @RequestMapping(value="/loadMsgImageUrl/{imageId}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	  public  @ResponseBody Object loadMsgImageUrl(@PathVariable("imageId")Long imageId){
	    
		 Optional<String> imgOp =cloudImageService.loadImageUrl(imageId);
		  
		 return ajaxQuery("imgUrl", imgOp.orElse(""));
	  }
	  
	  @ApiOperation(value = "获取视频播放url")
	  @RequestMapping(value="/loadMsgVedioUrl/{vedioId}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	  public  @ResponseBody Object loadMsgVedioUrl(@PathVariable("vedioId")Long vedioId){
	    
		 Optional<String> vedioOp =cloudVedioService.loadMsgVedioUrl(vedioId);
		  
		 return ajaxQuery("vedioUrl", vedioOp.orElse(""));
	  }

	 
	
    @RequestMapping(value="/loadMessageDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadMessageDataSet(@RequestBody Map<String,Object> params){
	    DataSet dataSet=  messageService.loadMessageDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	
    @RequestMapping(value="/loadMessage/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadMessage(@PathVariable("id")Long id){
		Optional<Message> ops = messageService.loadMessageById(id);
		return ajaxQuery("message",ops);
    }
	
    @RequestMapping(value="/deleteMessage/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object deleteMessage(@PathVariable("id")Long id){
		messageService.deleteMessage(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }
    

    @RequestMapping(value="/setMessageStatus/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object setMessageStatus(@PathVariable("id")Long id,Byte Status){
		messageService.setMessageStatus(id,Status);
		return ajaxDoneSuccess("数据操作成功 ");
    }


    
}